<?

class Admin_Sites extends MY_Controller {

    function Admin_Sites() {

        parent::MY_Controller(TRUE);

    }

    function index() {

        $this->mdl_sessions->set_last_index();

        $this->load->view('admin/sites_index');

    }

    function form() {

        if ($this->mdl_sites->validate()) {

            $this->mdl_sites->save();

            redirect('admin_sites/index');

        }

        else {

            if (!$_POST and $this->uri_assoc('site_id')) {

                $this->mdl_sites->prep_validation($this->mdl_sites->get(array('site_id'=>$this->uri_assoc('site_id'))));

            }

            $this->load->view('admin/sites_form');

        }

    }

    function delete() {

        $this->mdl_sites->delete();

        redirect($this->session->userdata('last_index'));

    }

    function switch_site() {

        $this->mdl_sites->set_site_session($this->input->post('site_id'));

        redirect('admin_index');

    }

    function set_default() {

        $this->mdl_sites->set_default($this->uri_assoc('site_id'));

        redirect('admin_sites/index');

    }

}

?>